//
// Created by Shao Wenhan on 2020/11/18.
//

#include <gtest/gtest.h>
#include <vector>
#include "Gain.h"

using namespace std;

class TestGain : public testing::Test
{
private:
    void assignGain(Gain &gain, DisType costGain, const vector<DisType> &penaltyGains)
    {
        gain.costGain = costGain;
        for(int i = 0; i < Constraint::num; i++)
            gain.penaltyGains[i] = penaltyGains[i];
    }
public:
    Gain m_gain;
    Gain m_bigGainWhoseCostGainBig;
    Gain m_bigGainWhoseCostGainIsEqualButFirstPenaltyGainBig;
    Gain m_anotherGain;
    Gain m_sumOfGainAndAnotherGain;

    TestGain() {
        assignGain(m_gain, 2, {2, 0});
        assignGain(m_bigGainWhoseCostGainBig, 5, {-2, -5});
        assignGain(m_bigGainWhoseCostGainIsEqualButFirstPenaltyGainBig, 2, {5, -2});
        assignGain(m_anotherGain, 5, {-2, 1});
        assignGain(m_sumOfGainAndAnotherGain, 7, {0, 1});
    }
};

TEST_F(TestGain, OverloadOperatorEqual)
{
    ASSERT_EQ(m_gain, m_gain);
    ASSERT_FALSE(m_gain == m_anotherGain);
}

TEST_F(TestGain, OverloadOperatorLess)
{
    ASSERT_TRUE(m_gain < m_bigGainWhoseCostGainIsEqualButFirstPenaltyGainBig);
    ASSERT_TRUE(m_gain < m_bigGainWhoseCostGainBig);
    ASSERT_FALSE(m_gain < m_gain);
    ASSERT_FALSE(m_bigGainWhoseCostGainBig < m_gain);
}

TEST_F(TestGain, OverloadOperatorAddAssign)
{
    m_gain += m_anotherGain;
    ASSERT_EQ(m_sumOfGainAndAnotherGain, m_gain);
}

TEST_F(TestGain, CopyConstructor)
{
    Gain copy(m_gain);
    ASSERT_EQ(copy, m_gain);
}